#include "DS18B20.h"

void Delay1ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
}

void ds18b20_zhuanhuan(void)
{
	onewrite_inti();
	Delay1ms();
	write_byte(T_ROM);
	write_byte(WD_ZH);
}

float ds18b20_read(void)
{
	u8 LSB = 0X00;
	u8 HSB = 0X00;
	int tmep = 0;
	float T = 0;
	onewrite_inti();
	Delay1ms();
	write_byte(T_ROM);
	write_byte(R_T);
	LSB = read_byte();
	HSB = read_byte();
	tmep = (HSB << 8)|LSB;
	T = tmep/16.0;
	return T;
}

